if (gpx_wversion_num > 10) {
writer->writeStartElement("metadata");
}
- gpx_write_gdata(&gpx_global->name, "name");
- gpx_write_gdata(&gpx_global->desc, "desc");
+ if (gpx_global) {
+ gpx_write_gdata(&gpx_global->name, "name");
+ gpx_write_gdata(&gpx_global->desc, "desc");
+ }
/* In GPX 1.1, author changed from a string to a PersonType.
* since it's optional, we just drop it instead of rewriting it.
*/
if (gpx_wversion_num < 11) {
- gpx_write_gdata(&gpx_global->author, "author");
+ if (gpx_global) {
+ gpx_write_gdata(&gpx_global->author, "author");
+ }
}
/* In GPX 1.1 email, url, urlname aren't allowed. */
if (gpx_wversion_num < 11) {
- gpx_write_gdata(&gpx_global->email, "email");
- gpx_write_gdata(&gpx_global->url, "url");
- gpx_write_gdata(&gpx_global->urlname, "urlname");
+ if (gpx_global) {
+ gpx_write_gdata(&gpx_global->email, "email");
+ gpx_write_gdata(&gpx_global->url, "url");
+ gpx_write_gdata(&gpx_global->urlname, "urlname");
+ }
}
gpsbabel::DateTime now = current_time();
writer->writeTextElement("time", now.toPrettyString());
- gpx_write_gdata(&gpx_global->keywords, "keywords");
+ if (gpx_global) {
+ gpx_write_gdata(&gpx_global->keywords, "keywords");
+ }
gpx_write_bounds();
}
- le_write32(&pWptHxTmp->pt.iLatitude,(unsigned int) lat);
- le_write32(&pWptHxTmp->pt.iLongitude,(unsigned int) lon);
+ // Note that conversions from double values to unsigned int
+ // yield undefined results for negative values.
+ // We intentionally convert to int, then do an implicit
+ // conversion to unsigned in the call.
+ le_write32(&pWptHxTmp->pt.iLatitude,(signed int) lat);
+ le_write32(&pWptHxTmp->pt.iLongitude,(signed int) lon);
pWptHxTmp->checked = 01;
pWptHxTmp->vocidx = (short)0xffff;
le_write16(&((WPTHDR*)HxWFile)->num, ++sIndex);
int32_t lat;
int32_t lon;
} *latlon;
+ struct ll mylatlon;
uint16_t coordcount;
route_head* track_head = NULL;
route_head* old_track_head = NULL;
wpt_tmp = new Waypoint;
+ // copy to make sure we don't violate alignment restrictions.
+ memcpy(&mylatlon,latlon,sizeof(mylatlon));
lat = (0x80000000UL -
- le_read32(&latlon->lat)) /
+ le_read32(&mylatlon.lat)) /
(double)(0x800000);
lon = (0x80000000UL -
- le_read32(&latlon->lon)) /
+ le_read32(&mylatlon.lon)) /
(double)(0x800000);
wpt_tmp->latitude = lat;
switch (unicsv_fields_tab[column]) {
case fld_latitude:
- human_to_dec(CSTR(s), &wpt->latitude, &wpt->longitude, 1);
+ human_to_dec(CSTR(s), &wpt->latitude, NULL, 1);
wpt->latitude = wpt->latitude * ns;
break;
case fld_longitude:
- human_to_dec(CSTR(s), &wpt->latitude, &wpt->longitude, 2);
+ human_to_dec(CSTR(s), NULL, &wpt->longitude, 2);
wpt->longitude = wpt->longitude * ew;
break;